//
//  MainViewController.swift
//  微博
//
//  Created by MI on 15/11/8.
//  Copyright © 2015年 young_Mi. All rights reserved.
//

import UIKit

class MainViewController: UITabBarController {
    
  @objc private func composeDidClick() {
    print(__FUNCTION__)
        
    
    }
    

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
        let maintabBar = MainTabBar()
        
        setValue(maintabBar, forKey: "tabBar")
        
        
        addChildViewController()
        
        maintabBar.composeBtn.addTarget(self, action: "composeDidClick", forControlEvents: .TouchUpInside)
        
    }

    
    private func addChildViewController(){
    addChildViewController(HomeTableViewController(), titlt: "首页", imageName: "tabbar_home")
     addChildViewController(MessageTableViewController(), titlt: "消息", imageName: "tabbar_message_center")
        addChildViewController(DiscoverTableViewController(), titlt: "发现", imageName: "tabbar_discover")
        addChildViewController(PeofileTableViewController(), titlt: "我", imageName: "tabbar_profile")
        
    }
    
    private func addChildViewController(vc: UIViewController, titlt: String, imageName: String) {
        //设置tabbar颜色
        self.tabBar.tintColor = UIColor.orangeColor()
        let nav = UINavigationController(rootViewController: vc)
        vc.title = titlt
        vc.tabBarItem.image = UIImage(named: imageName)

        
        //        vc.tabBarItem.selectedImage = UIImage(named: imageName + "_highlighted")?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal);
//        
//        vc.tabBarItem.setTitleTextAttributes([NSForegroundColorAttributeName: UIColor.orangeColor()], forState: .Selected)
        
        addChildViewController(nav)
   
        
    
    }


}
